import request from "@/axios/axios.ts";
import type {TestDataMake} from "@/api/first/SetUp/type.ts"
import {useStore} from '@/pinia'
import {BigDataMake} from "@/api/first/SetUp/type.ts";

const store = useStore()

enum API1 {
    MAKE_TEST_DATA = '/first/make_test_data',
    MAKE_BIG_DATA = '/first/make_big_data',
}
enum API2 {
    MAKE_TEST_DATA = '/second/make_big_data',
    MAKE_BIG_DATA = '/second/make_big_data',
}
enum API3 {
    MAKE_TEST_DATA = '/first_new/make_big_data',
    MAKE_BIG_DATA = '/first_new/make_big_data',
}

// 清空数据库并创建测试数据
export const reqMakeTestData = (data: TestDataMake): Promise<any> => {
    if (store.axios_path === '1')
        return request.post<any, any>(API1.MAKE_TEST_DATA, data)
    else if(store.axios_path === '2')
        return request.post<any, any>(API2.MAKE_TEST_DATA, data)
    else
        return request.post<any, any>(API3.MAKE_TEST_DATA, data)
}

// 根据小类数据重建大类数据
export const reqMakeBigData = (data: BigDataMake): Promise<any> => {
    if (store.axios_path === '1')
        return request.post<any, any>(API1.MAKE_BIG_DATA, data)
    else if(store.axios_path === '2')
        return request.post<any, any>(API2.MAKE_BIG_DATA, data)
    else
        return request.post<any, any>(API3.MAKE_BIG_DATA, data)
}
